package cn.baiyang.rocketmq.spring.autoconfigure.ratelimit;

import java.util.List;
import java.util.Set;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 *
 * @author hongzhu
 * @version V1.0
 * @since 2024-03-14 10:00
 */
@ConfigurationProperties(prefix = "bucket4j")
public class Bucket4jProperties {
    /**
     * Using Jedis Configuration
     */
    private Jedis jedis;

    /**
     * Using Redisson Configuration
     */
    private Redisson redisson;

    public Jedis getJedis() {
        return jedis;
    }

    public void setJedis(Jedis jedis) {
        this.jedis = jedis;
    }

    public Redisson getRedisson() {
        return redisson;
    }

    public void setRedisson(Redisson redisson) {
        this.redisson = redisson;
    }

    /**
     * Jedis Resource
     */
    public static class Jedis {
        /**
         * Redis user. More info see <a href="https://redis.io/docs/management/security/acl/">Redis ACL</a>
         */
        private String user;
        /**
         * Redis password
         */
        private String password;
        /**
         * Redis address. Single one, format is Host:Port
         */
        private String address;
        /**
         * Redis cluster address. Multiple acceptable, format is Host:Port
         */
        private List<String> clusterNodes;
        /**
         * Redis database. Default is 0.
         */
        private int database = 0;
        /**
         * Master node name in sentinel mode
         */
        private String masterName;
        /**
         * Sentinel address in sentinel mode. Multiple acceptable, format is Host:Port
         */
        private Set<String> sentinelNodes;

        public int getDatabase() {
            return database;
        }

        public void setDatabase(int database) {
            this.database = database;
        }

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public List<String> getClusterNodes() {
            return clusterNodes;
        }

        public void setClusterNodes(List<String> clusterNodes) {
            this.clusterNodes = clusterNodes;
        }

        public String getMasterName() {
            return masterName;
        }

        public void setMasterName(String masterName) {
            this.masterName = masterName;
        }

        public Set<String> getSentinelNodes() {
            return sentinelNodes;
        }

        public void setSentinelNodes(Set<String> sentinelNodes) {
            this.sentinelNodes = sentinelNodes;
        }
    }

    /**
     * Redisson Resource
     */
    public static class Redisson {
        /**
         * Redis user. More info see <a href="https://redis.io/docs/management/security/acl/">Redis ACL</a>
         */
        private String user;
        /**
         * Redis password
         */
        private String password;
        /**
         * Redis address. Single one, format is Host:Port
         */
        private String address;
        /**
         * Redis cluster address. Multiple acceptable, format is Host:Port
         */
        private List<String> clusterNodes;
        /**
         * Redis database. Default is 0.
         */
        private int database = 0;
        /**
         * Master node name in sentinel mode
         */
        private String masterName;
        /**
         * Sentinel address in sentinel mode. Multiple acceptable, format is Host:Port
         */
        private Set<String> sentinelNodes;

        public int getDatabase() {
            return database;
        }

        public void setDatabase(int database) {
            this.database = database;
        }

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public List<String> getClusterNodes() {
            return clusterNodes;
        }

        public void setClusterNodes(List<String> clusterNodes) {
            this.clusterNodes = clusterNodes;
        }

        public String getMasterName() {
            return masterName;
        }

        public void setMasterName(String masterName) {
            this.masterName = masterName;
        }

        public Set<String> getSentinelNodes() {
            return sentinelNodes;
        }

        public void setSentinelNodes(Set<String> sentinelNodes) {
            this.sentinelNodes = sentinelNodes;
        }
    }

}
